package com.moorror.codegenvel.utils;

import com.intellij.openapi.project.Project;
import com.moorror.codegenvel.common.tree.TreePanelMark;
import com.moorror.codegenvel.view.component.CodeGenByVelocityComponent;
import com.moorror.codegenvel.view.component.TabContentRightShow;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;

/**
 * @Author jiyanghuang
 * @Date 2025/10/27 01:12
 */
public class TabLeftUtils {

    public static <T> T rootModel(Project project){
        TabContentRightShow tabContentRightShow = CodeGenByVelocityComponent.getInstance(project).findInstance(TabContentRightShow.class);
        TreePanelMark treePanelMark = tabContentRightShow.getT();
        TreeNode firstChild = treePanelMark.rootTreeNode().getFirstChild();
        if(null != firstChild){
            DefaultMutableTreeNode mutableTreeNode = (DefaultMutableTreeNode)firstChild;
            return (T)mutableTreeNode.getUserObject();
        }
        return null;
    }
}
